package com.huiyuan.service.impl;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.huiyuan.mapper.UserMapper;
import com.huiyuan.common.User;
import com.huiyuan.service.UserService;

import java.math.BigDecimal;

/**
 * @author huiyuan080
 * @data 2023/5/2
 * @apiNote
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public int deleteByPrimaryKey(Integer userId) {
        return userMapper.deleteByPrimaryKey(userId);
    }

    @Override
    public int insert(User record) {
        return userMapper.insert(record);
    }

    @Override
    public int insertSelective(User record) {
        return userMapper.insertSelective(record);
    }

    @Override
    public User selectByPrimaryKey(Integer userId) {
        return userMapper.selectByPrimaryKey(userId);
    }

    @Override
    public int updateByPrimaryKeySelective(User record) {
        return userMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(User record) {
        return userMapper.updateByPrimaryKey(record);
    }

    /**
     * 用户充值服务
     *
     * @param userId
     * @param price
     * @return
     */
    @Override
    public int recharge(Integer userId, BigDecimal price) {
        return userMapper.recharge(userId, price);
    }


    /**
     * 修改用户是否用车
     *
     * @param userId
     * @return
     */
    @Override
    public int addUse(Integer userId) {
        return userMapper.addUse(userId);
    }


    /**
     * 查询用户是否租从车
     * @param userId
     * @return
     */
    @Override
    public User isNull(Integer userId) {

        return userMapper.isNull(userId);
    }
}
